var CryptoJS = require('crypto-js');

export const encrypt = function (keyStr, pwd) {
  var key = CryptoJS.enc.Utf8.parse(keyStr)
  var pwdI = CryptoJS.enc.Utf8.parse(pwd);
  var pwdCry = CryptoJS.AES.encrypt(pwdI, key, {
    mode: CryptoJS.mode.ECB,
    padding: CryptoJS.pad.Pkcs7
  }); // AES
  // var pwdCry = CryptoJS.MD5(keyStr + pwd); // AES
  return pwdCry.toString();
}

export const decrypt = function (keyStr, pwdCry) {
  var key = CryptoJS.enc.Utf8.parse(keyStr)
  var pwdI = CryptoJS.AES.decrypt(pwdCry, key, {
    mode: CryptoJS.mode.ECB,
    padding: CryptoJS.pad.Pkcs7
  })
  return CryptoJS.enc.UTF8.stringify(pwdI).toString()
}
